// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: wsfuyibing <682805@qq.com>
// Date: 2024-11-12

package base

import "strings"

// Adapter
// 日志适配, 定义日志输出到哪里, 内置支持下列几种类型.
type Adapter string

const (
	AdapterTerm    Adapter = "term"    // 1. 在终端打印
	AdapterFile    Adapter = "file"    // 2. 写入到本地文件中
	AdapterElastic Adapter = "elastic" // 3. 发送到 Elasticsearch (https://www.elastic.co/cn/elasticsearch)
	AdapterKafka   Adapter = "kafka"   // 4. 发送到 Kafka (https://kafka.apache.org/)
)

// Defaulter
// 计算默认值.
func (o Adapter) Defaulter() Adapter {
	v := Adapter(strings.ToLower(o.String()))
	switch v {
	case AdapterFile, AdapterElastic, AdapterKafka:
		return v
	}
	return AdapterTerm
}

// String
// 转成字符串.
func (o Adapter) String() string {
	return string(o)
}
